{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "notebook.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LLWBN5CykNcr",
        "colab_type": "text"
      },
      "source": [
        "## Install Dependencies"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3DS5c4fU5anq",
        "colab_type": "text"
      },
      "source": [
        "### mesa"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "i93i258hqkLK",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!apt-get update\n",
        "!apt-get install llvm-6.0 llvm-6.0-tools\n",
        "!wget https://github.com/mmatl/travis_debs/raw/master/xenial/mesa_18.3.3-0.deb\n",
        "!dpkg -i ./mesa_18.3.3-0.deb || true\n",
        "!apt-get install -f"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iHAJGJ4n5dyk",
        "colab_type": "text"
      },
      "source": [
        "### SPIN"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "jFUGIM-8hYom",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!git clone https://github.com/nkolot/SPIN.git\n",
        "%cd SPIN\n",
        "!pip install -r requirements.txt\n",
        "!pip uninstall pyopengl scipy -y\n",
        "!pip install git+https://github.com/mmatl/pyopengl.git\n",
        "!pip install scipy==1.1.0"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "CIdzL_hJtwio",
        "colab_type": "text"
      },
      "source": [
        "## Download Dataset / Model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "43rM3oj1lpec",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!./fetch_data.sh"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YXMhFB3AyOD9",
        "colab_type": "text"
      },
      "source": [
        "### Retrieve SMPL Dataset"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "EXE3hu2_yWcv",
        "colab_type": "text"
      },
      "source": [
        "You will need the [neutral model](http://smplify.is.tue.mpg.de) for training and running the demo code, while the [male and female models](http://smpl.is.tue.mpg.de/) will be necessary for evaluation on the 3DPW dataset."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "2cAFKs4p2E2y",
        "colab_type": "text"
      },
      "source": [
        "#### Neural Model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8PzUOaSNyR_Z",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# http://smpl.is.tue.mpg.de/ (Neutral Model)\n",
        "#!wget http://smpl.is.tue.mpg.de -O SMPL_python_v.1.0.0.zip\n",
        "!unzip SMPL_python_v.1.0.0.zip -d data && rm -rf data/__MACOSX && rm -r SMPL_python_v.1.0.0.zip"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_Gyu39Cu1EPI",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Only pull smplx and install chumpy once (if you did it for male / female models already)\n",
        "!git clone https://github.com/vchoutas/smplx.git\n",
        "!pip2 install chumpy\n",
        "!python2 smplx/tools/clean_ch.py --input-models data/smpl/models/*.pkl --output-folder data/smpl\n",
        "\n",
        "# Rename basicModel_neutral_lbs_10_207_0_v1.0.0.pkl to SMPL_NEUTRAL.pkl\n",
        "!mv data/smpl/basicModel_neutral_lbs_10_207_0_v1.0.0.pkl data/smpl/SMPL_NEUTRAL.pkl"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8RqG3-iP2Ho9",
        "colab_type": "text"
      },
      "source": [
        "#### Male and Female Models"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Eykpa1LD0zMZ",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# http://smplify.is.tue.mpg.de (Male and Female Models)\n",
        "#!wget http://smplify.is.tue.mpg.de -O mpips-smplify_public_v2.zip\n",
        "!unzip mpips-smplify_public_v2.zip -d data && rm -r mpips-smplify_public_v2.zip"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "FVAqTXi417gN",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Only pull smplx and install chumpy once (if you did in previous neurtal model)\n",
        "!git clone https://github.com/vchoutas/smplx.git\n",
        "!pip2 install chumpy\n",
        "!python2 smplx/tools/clean_ch.py --input-models data/smplify_public/code/models/*.pkl --output-folder data/smpl"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "I9p6oOxNngHE",
        "colab_type": "text"
      },
      "source": [
        "## Run Demo"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "XU0LAoJg7vGz",
        "colab_type": "text"
      },
      "source": [
        "### Neural Model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "27WaJMuyni6j",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "%%bash\n",
        "python3 demo.py \\\n",
        "  --checkpoint=data/model_checkpoint.pt \\\n",
        "  --img=examples/im1010.jpg \\\n",
        "  --openpose=examples/im1010_openpose.json"
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}